<?php
/**
 * Created by PhpStorm.
 * User: surface
 * Date: 2018/12/13
 * Time: 11:58
 */

namespace app\common\validate;

use think\Validate;

class Room extends Validate
{
    protected $rule = [
        'name' => 'require|max:100',
        'brief' => 'max:255',
        'mktprice' => 'float',
        'price' => 'float',
        'image_id' => 'require',
        'sort' => 'number|max:5',
        'bn'=>'unique:goods',
    ];

    protected $scene = [
        'edit'  =>  ['name','brief','mktprice','price','image_id','sort','bn'=>'unique:room,bn^id'],
        'import'  =>  ['name','brief','mktprice','price','stock','sort'],
    ];

    protected $message = [
        'name.require' => '房间名称必填',
        'name.max' => '房间名称最长100个字符',
        'brief.max' => '房间简介最多255个字符',
        'mktprice' => '请输入正确的到店价',
        'price' => '请输入正确的会员价',
        'image_id.require' => '图片不能为空',
        'sort.number' => '房间排序非法',
        'sort.max' => '房间排序最多只能输入5位数字',
        'bn.unique' => '房间编号不能重复',
    ];
}